import json
import math


def calcPoints(distances):
    # if len(distances) != 1000:
    #     raise ValueError("distances must be 1000 elements")
    angle = 0
    res = []
    for distance in distances:
        if distance == float("inf") or distance < 0:
            x = -0.1
            y = -0.1
        else:
            x = distance * math.sin(math.radians(360 - angle))
            y = distance * math.cos(math.radians(360 - angle))
        angle += 0.36
        res.append([x, y])
    return res


if __name__ == "__main__":
    distances = json.load(open("scan.json", "r"))["ranges"][:1000]
    print(calcPoints(distances))
